from django.db import models
from django.utils import timezone

# Create your models here.
class UserInfo(models.Model):
    username = models.CharField(verbose_name="用户名", max_length=128)
    password = models.CharField(verbose_name="密码", max_length=128)
    email = models.EmailField(verbose_name="邮箱", max_length=128)
    sex_choices = ((1, "男"),(2, "女"))
    sex = models.SmallIntegerField(verbose_name="性别", choices=sex_choices)
    location_x = models.FloatField(verbose_name="x坐标", max_length=128)
    location_y = models.FloatField(verbose_name="y坐标", max_length=128)
    createAt = models.DateTimeField(verbose_name="创建日期", default=timezone.now)


class ScheduleInfo(models.Model):
    user_id = models.ForeignKey(to="UserInfo", to_field="id",null=True, blank=True, on_delete=models.SET_NULL)
    address = models.CharField(verbose_name="地点", max_length=512)
    time = models.TimeField(verbose_name="时间", default=timezone.now)
    introduction = models.CharField(verbose_name="简介", max_length=512)
    location_x = models.FloatField(verbose_name="x坐标", max_length=128)
    location_y = models.FloatField(verbose_name="y坐标", max_length=128)
    createAt = models.DateTimeField(verbose_name="创建日期", default=timezone.now)
    


"""会翻译成以下sql语句
create table app01_userinfo(
    id bigint auto_increment primary key,
    name varchar(32),
    password varchar(64),
    age int
)
"""